<template>
  <el-dialog
    :close-on-click-modal="false"
    width="30%"
    title="项目阶段列表"
    :visible.sync="checkVisible"
    :before-close="cancelAdd"
    append-to-body
  >
    <div v-for="(thing,index) in datas.list" :key="index">
      <div class="things-item" @click="checkChange(thing)">
        <span class="item-title">{{` 阶段：${thing.name}`}}</span>
        <i v-if="thing.r_ischeck==1" class="el-icon-circle-check" style="color:#67C23A" />
        <i v-if="thing.r_ischeck==0" class="el-icon-circle-close" />
      </div>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancelAdd">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import disposeAPI from "@apis/projectDispose";
import { Message } from "element-ui";

export default {
  name: "InnerDialog",
  props: {
    baseStyle: Object,
    cancel: Function,
  },
  data() {
    return {
      checkVisible: false,
      datas: {}
    };
  },
  computed: {},
  created() {},
  methods: {
    getDatas(id) {
      disposeAPI
        .getPLanList(id)
        .then(res => {
            this.datas={...res};
        })
        .catch(err => {
          // return row.status;
        });
    },
    openAddThings() {
      this.checkVisible = true;
    },
    cancelAdd() {
      this.checkVisible = false;
      this.$emit("cancel");
    },
    //标记需要评审的阶段
    markStage(parmars) {
      disposeAPI
        .setStageStatus(parmars)
        .then(res => {
            this.getDatas(parmars.class_id);
        })
        .catch(err => {
          this.$message.error(err.message);
        });
    },
    checkChange(row) {
      let parmars = {
        class_id: row.class_id,
        stage_id: row.stage_id,
        status: 1
      };
      this.$confirm("是否标记为需要评审阶段?", "提示", {
        closeOnClickModal: false,
        confirmButtonText: "确定标记",
        cancelButtonText: "取消标记",
        type: "warning",
        distinguishCancelAndClose: true
      })
        .then(() => {
          parmars.status = 1;
          this.markStage(parmars);
        })
        .catch(action => {
          if (action == "cancel") {
            parmars.status = 0;
            this.markStage(parmars);
          }
        });
    },
    setDatas(data) {
        this.getDatas(data.id);
    }
  }
};
</script>
<style lang="scss" scoped>
.things-item {
  padding: 5px 0;
  cursor: pointer;
}
.things-item .item-title {
  padding-right: 20px;
  color: #409eff;
}
</style>